﻿// Decompiled with JetBrains decompiler
// Type: UnityEngine.Experimental.Rendering.RayTracingShader
// Assembly: UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E6AE6B5A-2752-4B07-9528-C8B77C62CE79
// Assembly location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll
// XML documentation location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.xml

using System.Runtime.CompilerServices;
using UnityEngine.Bindings;

#nullable disable
namespace UnityEngine.Experimental.Rendering
{
  /// <summary>
  ///   <para>A shader for GPU ray tracing.</para>
  /// </summary>
  [NativeHeader("Runtime/Shaders/RayTracingShader.h")]
  [NativeHeader("Runtime/Graphics/ShaderScriptBindings.h")]
  [NativeHeader("Runtime/Shaders/RayTracingAccelerationStructure.h")]
  public sealed class RayTracingShader : Object
  {
    /// <summary>
    ///   <para>The maximum number of ray bounces this shader can trace (Read Only).</para>
    /// </summary>
    public extern float maxRecursionDepth { [MethodImpl(MethodImplOptions.InternalCall)] get; }

    /// <summary>
    ///   <para>Sets the value of a float uniform.</para>
    /// </summary>
    /// <param name="name">The name of the property being set.</param>
    /// <param name="nameID">The ID of the property as given by Shader.PropertyToID.</param>
    /// <param name="val">The float value to set.</param>
    [FreeFunction(Name = "RayTracingShaderScripting::SetFloat", HasExplicitThis = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    public extern void SetFloat(int nameID, float val);

    /// <summary>
    ///   <para>Sets the value of a int uniform.</para>
    /// </summary>
    /// <param name="name">The name of the property being set.</param>
    /// <param name="nameID">The ID of the property as given by Shader.PropertyToID.</param>
    /// <param name="val">The int value to set.</param>
    [FreeFunction(Name = "RayTracingShaderScripting::SetInt", HasExplicitThis = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    public extern void SetInt(int nameID, int val);

    /// <summary>
    ///   <para>Sets the value for a vector uniform.</para>
    /// </summary>
    /// <param name="name">The name of the property being set.</param>
    /// <param name="nameID">The ID of the property as given by Shader.PropertyToID.</param>
    /// <param name="val">The vector to set.</param>
    [FreeFunction(Name = "RayTracingShaderScripting::SetVector", HasExplicitThis = true)]
    public void SetVector(int nameID, Vector4 val) => this.SetVector_Injected(nameID, ref val);

    /// <summary>
    ///   <para>Sets the value of a matrix uniform.</para>
    /// </summary>
    /// <param name="name">The name of the property being set.</param>
    /// <param name="nameID">The ID of the property as given by Shader.PropertyToID.</param>
    /// <param name="val">The matrix to set.</param>
    [FreeFunction(Name = "RayTracingShaderScripting::SetMatrix", HasExplicitThis = true)]
    public void SetMatrix(int nameID, Matrix4x4 val) => this.SetMatrix_Injected(nameID, ref val);

    [FreeFunction(Name = "RayTracingShaderScripting::SetFloatArray", HasExplicitThis = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern void SetFloatArray(int nameID, float[] values);

    [FreeFunction(Name = "RayTracingShaderScripting::SetIntArray", HasExplicitThis = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern void SetIntArray(int nameID, int[] values);

    /// <summary>
    ///   <para>Sets a vector array uniform.</para>
    /// </summary>
    /// <param name="name">The name of the property being set.</param>
    /// <param name="nameID">The ID of the property as given by Shader.PropertyToID.</param>
    /// <param name="values">The array of vectors to set.</param>
    [FreeFunction(Name = "RayTracingShaderScripting::SetVectorArray", HasExplicitThis = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    public extern void SetVectorArray(int nameID, Vector4[] values);

    /// <summary>
    ///   <para>Sets a matrix array uniform.</para>
    /// </summary>
    /// <param name="name">The name of the property being set.</param>
    /// <param name="nameID">The ID of the property as given by Shader.PropertyToID.</param>
    /// <param name="values">The matrix array to set.</param>
    [FreeFunction(Name = "RayTracingShaderScripting::SetMatrixArray", HasExplicitThis = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    public extern void SetMatrixArray(int nameID, Matrix4x4[] values);

    /// <summary>
    ///   <para>Binds a texture resource. This can be a input or an output texture (UAV).</para>
    /// </summary>
    /// <param name="nameID">The ID of the resource as given by Shader.PropertyToID.</param>
    /// <param name="name">The name of the texture being set.</param>
    /// <param name="texture">The texture to bind the named local resource to.</param>
    [NativeMethod(Name = "RayTracingShaderScripting::SetTexture", HasExplicitThis = true, IsFreeFunction = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    public extern void SetTexture(int nameID, [NotNull("ArgumentNullException")] Texture texture);

    /// <summary>
    ///   <para>Binds a ComputeBuffer or GraphicsBuffer to a RayTracingShader.</para>
    /// </summary>
    /// <param name="nameID">The ID of the buffer name in shader code. Use Shader.PropertyToID to get this ID.</param>
    /// <param name="name">The name of the buffer in shader code.</param>
    /// <param name="buffer">The buffer to bind the named local resource to.</param>
    [NativeMethod(Name = "RayTracingShaderScripting::SetBuffer", HasExplicitThis = true, IsFreeFunction = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    public extern void SetBuffer(int nameID, [NotNull("ArgumentNullException")] ComputeBuffer buffer);

    [NativeMethod(Name = "RayTracingShaderScripting::SetBuffer", HasExplicitThis = true, IsFreeFunction = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern void SetGraphicsBuffer(int nameID, [NotNull("ArgumentNullException")] GraphicsBuffer buffer);

    [FreeFunction(Name = "RayTracingShaderScripting::SetConstantBuffer", HasExplicitThis = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern void SetConstantComputeBuffer(
      int nameID,
      [NotNull("ArgumentNullException")] ComputeBuffer buffer,
      int offset,
      int size);

    [FreeFunction(Name = "RayTracingShaderScripting::SetConstantBuffer", HasExplicitThis = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern void SetConstantGraphicsBuffer(
      int nameID,
      [NotNull("ArgumentNullException")] GraphicsBuffer buffer,
      int offset,
      int size);

    /// <summary>
    ///   <para>Sets the value for RayTracingAccelerationStructure property of this RayTracingShader.</para>
    /// </summary>
    /// <param name="name">The name of the RayTracingAccelerationStructure being set.</param>
    /// <param name="nameID">The ID of the RayTracingAccelerationStructure as given by Shader.PropertyToID.</param>
    /// <param name="accelerationStructure">The value to set the RayTracingAccelerationStructure to.</param>
    [NativeMethod(Name = "RayTracingShaderScripting::SetAccelerationStructure", HasExplicitThis = true, IsFreeFunction = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    public extern void SetAccelerationStructure(
      int nameID,
      [NotNull("ArgumentNullException")] RayTracingAccelerationStructure accelerationStructure);

    /// <summary>
    ///   <para>Selects which Shader Pass to use when executing ray/geometry intersection shaders.</para>
    /// </summary>
    /// <param name="passName">The Shader Pass to use when executing ray tracing shaders.</param>
    [MethodImpl(MethodImplOptions.InternalCall)]
    public extern void SetShaderPass(string passName);

    /// <summary>
    ///   <para>Binds a global texture to a RayTracingShader.</para>
    /// </summary>
    /// <param name="nameID">The ID of the texture as given by Shader.PropertyToID.</param>
    /// <param name="name">The name of the texture to bind.</param>
    /// <param name="globalTextureName">The name of the global resource to bind to the RayTracingShader.</param>
    /// <param name="globalTextureNameID">The ID of the global resource as given by Shader.PropertyToID.</param>
    [NativeMethod(Name = "RayTracingShaderScripting::SetTextureFromGlobal", HasExplicitThis = true, IsFreeFunction = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    public extern void SetTextureFromGlobal(int nameID, int globalTextureNameID);

    /// <summary>
    ///   <para>Dispatches this RayTracingShader.</para>
    /// </summary>
    /// <param name="rayGenFunctionName">The name of the ray generation shader.</param>
    /// <param name="width">The width of the ray generation shader thread grid.</param>
    /// <param name="height">The height of the ray generation shader thread grid.</param>
    /// <param name="depth">The depth of the ray generation shader thread grid.</param>
    /// <param name="camera">Optional parameter used to setup camera-related built-in shader variables.</param>
    [NativeName("DispatchRays")]
    [MethodImpl(MethodImplOptions.InternalCall)]
    public extern void Dispatch(
      string rayGenFunctionName,
      int width,
      int height,
      int depth,
      Camera camera = null);

    /// <summary>
    ///   <para>Binds a ComputeBuffer or GraphicsBuffer to a RayTracingShader.</para>
    /// </summary>
    /// <param name="nameID">The ID of the buffer name in shader code. Use Shader.PropertyToID to get this ID.</param>
    /// <param name="name">The name of the buffer in shader code.</param>
    /// <param name="buffer">The buffer to bind the named local resource to.</param>
    public void SetBuffer(int nameID, GraphicsBuffer buffer)
    {
      this.SetGraphicsBuffer(nameID, buffer);
    }

    private RayTracingShader()
    {
    }

    /// <summary>
    ///   <para>Sets the value of a float uniform.</para>
    /// </summary>
    /// <param name="name">The name of the property being set.</param>
    /// <param name="nameID">The ID of the property as given by Shader.PropertyToID.</param>
    /// <param name="val">The float value to set.</param>
    public void SetFloat(string name, float val) => this.SetFloat(Shader.PropertyToID(name), val);

    /// <summary>
    ///   <para>Sets the value of a int uniform.</para>
    /// </summary>
    /// <param name="name">The name of the property being set.</param>
    /// <param name="nameID">The ID of the property as given by Shader.PropertyToID.</param>
    /// <param name="val">The int value to set.</param>
    public void SetInt(string name, int val) => this.SetInt(Shader.PropertyToID(name), val);

    /// <summary>
    ///   <para>Sets the value for a vector uniform.</para>
    /// </summary>
    /// <param name="name">The name of the property being set.</param>
    /// <param name="nameID">The ID of the property as given by Shader.PropertyToID.</param>
    /// <param name="val">The vector to set.</param>
    public void SetVector(string name, Vector4 val)
    {
      this.SetVector(Shader.PropertyToID(name), val);
    }

    /// <summary>
    ///   <para>Sets the value of a matrix uniform.</para>
    /// </summary>
    /// <param name="name">The name of the property being set.</param>
    /// <param name="nameID">The ID of the property as given by Shader.PropertyToID.</param>
    /// <param name="val">The matrix to set.</param>
    public void SetMatrix(string name, Matrix4x4 val)
    {
      this.SetMatrix(Shader.PropertyToID(name), val);
    }

    /// <summary>
    ///   <para>Sets a vector array uniform.</para>
    /// </summary>
    /// <param name="name">The name of the property being set.</param>
    /// <param name="nameID">The ID of the property as given by Shader.PropertyToID.</param>
    /// <param name="values">The array of vectors to set.</param>
    public void SetVectorArray(string name, Vector4[] values)
    {
      this.SetVectorArray(Shader.PropertyToID(name), values);
    }

    /// <summary>
    ///   <para>Sets a matrix array uniform.</para>
    /// </summary>
    /// <param name="name">The name of the property being set.</param>
    /// <param name="nameID">The ID of the property as given by Shader.PropertyToID.</param>
    /// <param name="values">The matrix array to set.</param>
    public void SetMatrixArray(string name, Matrix4x4[] values)
    {
      this.SetMatrixArray(Shader.PropertyToID(name), values);
    }

    /// <summary>
    ///   <para>Sets the values for a float array uniform.</para>
    /// </summary>
    /// <param name="name">The name of the property being set.</param>
    /// <param name="nameID">The ID of the property as given by Shader.PropertyToID.</param>
    /// <param name="values">The float array to set.</param>
    public void SetFloats(string name, params float[] values)
    {
      this.SetFloatArray(Shader.PropertyToID(name), values);
    }

    /// <summary>
    ///   <para>Sets the values for a float array uniform.</para>
    /// </summary>
    /// <param name="name">The name of the property being set.</param>
    /// <param name="nameID">The ID of the property as given by Shader.PropertyToID.</param>
    /// <param name="values">The float array to set.</param>
    public void SetFloats(int nameID, params float[] values) => this.SetFloatArray(nameID, values);

    /// <summary>
    ///   <para>Sets the values for a int array uniform.</para>
    /// </summary>
    /// <param name="name">The name of the property being set.</param>
    /// <param name="nameID">The ID of the property as given by Shader.PropertyToID.</param>
    /// <param name="values">The int array to set.</param>
    public void SetInts(string name, params int[] values)
    {
      this.SetIntArray(Shader.PropertyToID(name), values);
    }

    /// <summary>
    ///   <para>Sets the values for a int array uniform.</para>
    /// </summary>
    /// <param name="name">The name of the property being set.</param>
    /// <param name="nameID">The ID of the property as given by Shader.PropertyToID.</param>
    /// <param name="values">The int array to set.</param>
    public void SetInts(int nameID, params int[] values) => this.SetIntArray(nameID, values);

    /// <summary>
    ///   <para>Sets the value of a boolean uniform.</para>
    /// </summary>
    /// <param name="name">The name of the property being set.</param>
    /// <param name="nameID">The ID of the property as given by Shader.PropertyToID.</param>
    /// <param name="val">The boolean value to set.</param>
    public void SetBool(string name, bool val)
    {
      this.SetInt(Shader.PropertyToID(name), val ? 1 : 0);
    }

    /// <summary>
    ///   <para>Sets the value of a boolean uniform.</para>
    /// </summary>
    /// <param name="name">The name of the property being set.</param>
    /// <param name="nameID">The ID of the property as given by Shader.PropertyToID.</param>
    /// <param name="val">The boolean value to set.</param>
    public void SetBool(int nameID, bool val) => this.SetInt(nameID, val ? 1 : 0);

    /// <summary>
    ///   <para>Binds a texture resource. This can be a input or an output texture (UAV).</para>
    /// </summary>
    /// <param name="nameID">The ID of the resource as given by Shader.PropertyToID.</param>
    /// <param name="name">The name of the texture being set.</param>
    /// <param name="texture">The texture to bind the named local resource to.</param>
    public void SetTexture(string name, Texture texture)
    {
      this.SetTexture(Shader.PropertyToID(name), texture);
    }

    /// <summary>
    ///   <para>Binds a ComputeBuffer or GraphicsBuffer to a RayTracingShader.</para>
    /// </summary>
    /// <param name="nameID">The ID of the buffer name in shader code. Use Shader.PropertyToID to get this ID.</param>
    /// <param name="name">The name of the buffer in shader code.</param>
    /// <param name="buffer">The buffer to bind the named local resource to.</param>
    public void SetBuffer(string name, ComputeBuffer buffer)
    {
      this.SetBuffer(Shader.PropertyToID(name), buffer);
    }

    /// <summary>
    ///   <para>Binds a ComputeBuffer or GraphicsBuffer to a RayTracingShader.</para>
    /// </summary>
    /// <param name="nameID">The ID of the buffer name in shader code. Use Shader.PropertyToID to get this ID.</param>
    /// <param name="name">The name of the buffer in shader code.</param>
    /// <param name="buffer">The buffer to bind the named local resource to.</param>
    public void SetBuffer(string name, GraphicsBuffer buffer)
    {
      this.SetBuffer(Shader.PropertyToID(name), buffer);
    }

    /// <summary>
    ///   <para>Binds a constant buffer created through a ComputeBuffer or a GraphicsBuffer.</para>
    /// </summary>
    /// <param name="nameID">The ID of the property name for the constant buffer in shader code. Use Shader.PropertyToID to get this ID.</param>
    /// <param name="name">The name of the constant buffer in shader code.</param>
    /// <param name="buffer">The buffer to bind as constant buffer.</param>
    /// <param name="offset">The offset in bytes from the beginning of the ComputeBuffer or GraphicsBuffer to bind. Must be a multiple of SystemInfo.constantBufferOffsetAlignment, or 0 if that value is 0.</param>
    /// <param name="size">The number of bytes to bind.</param>
    public void SetConstantBuffer(int nameID, ComputeBuffer buffer, int offset, int size)
    {
      this.SetConstantComputeBuffer(nameID, buffer, offset, size);
    }

    /// <summary>
    ///   <para>Binds a constant buffer created through a ComputeBuffer or a GraphicsBuffer.</para>
    /// </summary>
    /// <param name="nameID">The ID of the property name for the constant buffer in shader code. Use Shader.PropertyToID to get this ID.</param>
    /// <param name="name">The name of the constant buffer in shader code.</param>
    /// <param name="buffer">The buffer to bind as constant buffer.</param>
    /// <param name="offset">The offset in bytes from the beginning of the ComputeBuffer or GraphicsBuffer to bind. Must be a multiple of SystemInfo.constantBufferOffsetAlignment, or 0 if that value is 0.</param>
    /// <param name="size">The number of bytes to bind.</param>
    public void SetConstantBuffer(string name, ComputeBuffer buffer, int offset, int size)
    {
      this.SetConstantComputeBuffer(Shader.PropertyToID(name), buffer, offset, size);
    }

    /// <summary>
    ///   <para>Binds a constant buffer created through a ComputeBuffer or a GraphicsBuffer.</para>
    /// </summary>
    /// <param name="nameID">The ID of the property name for the constant buffer in shader code. Use Shader.PropertyToID to get this ID.</param>
    /// <param name="name">The name of the constant buffer in shader code.</param>
    /// <param name="buffer">The buffer to bind as constant buffer.</param>
    /// <param name="offset">The offset in bytes from the beginning of the ComputeBuffer or GraphicsBuffer to bind. Must be a multiple of SystemInfo.constantBufferOffsetAlignment, or 0 if that value is 0.</param>
    /// <param name="size">The number of bytes to bind.</param>
    public void SetConstantBuffer(int nameID, GraphicsBuffer buffer, int offset, int size)
    {
      this.SetConstantGraphicsBuffer(nameID, buffer, offset, size);
    }

    /// <summary>
    ///   <para>Binds a constant buffer created through a ComputeBuffer or a GraphicsBuffer.</para>
    /// </summary>
    /// <param name="nameID">The ID of the property name for the constant buffer in shader code. Use Shader.PropertyToID to get this ID.</param>
    /// <param name="name">The name of the constant buffer in shader code.</param>
    /// <param name="buffer">The buffer to bind as constant buffer.</param>
    /// <param name="offset">The offset in bytes from the beginning of the ComputeBuffer or GraphicsBuffer to bind. Must be a multiple of SystemInfo.constantBufferOffsetAlignment, or 0 if that value is 0.</param>
    /// <param name="size">The number of bytes to bind.</param>
    public void SetConstantBuffer(string name, GraphicsBuffer buffer, int offset, int size)
    {
      this.SetConstantGraphicsBuffer(Shader.PropertyToID(name), buffer, offset, size);
    }

    /// <summary>
    ///   <para>Sets the value for RayTracingAccelerationStructure property of this RayTracingShader.</para>
    /// </summary>
    /// <param name="name">The name of the RayTracingAccelerationStructure being set.</param>
    /// <param name="nameID">The ID of the RayTracingAccelerationStructure as given by Shader.PropertyToID.</param>
    /// <param name="accelerationStructure">The value to set the RayTracingAccelerationStructure to.</param>
    public void SetAccelerationStructure(
      string name,
      RayTracingAccelerationStructure accelerationStructure)
    {
      this.SetAccelerationStructure(Shader.PropertyToID(name), accelerationStructure);
    }

    /// <summary>
    ///   <para>Binds a global texture to a RayTracingShader.</para>
    /// </summary>
    /// <param name="nameID">The ID of the texture as given by Shader.PropertyToID.</param>
    /// <param name="name">The name of the texture to bind.</param>
    /// <param name="globalTextureName">The name of the global resource to bind to the RayTracingShader.</param>
    /// <param name="globalTextureNameID">The ID of the global resource as given by Shader.PropertyToID.</param>
    public void SetTextureFromGlobal(string name, string globalTextureName)
    {
      this.SetTextureFromGlobal(Shader.PropertyToID(name), Shader.PropertyToID(globalTextureName));
    }

    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern void SetVector_Injected(int nameID, ref Vector4 val);

    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern void SetMatrix_Injected(int nameID, ref Matrix4x4 val);
  }
}
